<template>
    <div>
        <el-dialog
                title="查询商户"
                :visible.sync="dialogVisible"
                width="50%">
            <el-table :data="commercialList">
                <el-table-column prop="uname" label="用户名"></el-table-column>
                <el-table-column label="操作">
                    <template slot-scope="scope">
                        <el-button size="mini" type="danger" @click="select(scope.row)">选择该商户</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div>
                <!-- 分页 -->
                <el-pagination
                        @size-change="handleSizeChange"
                        @current-change="handleCurrentChange"
                        :current-page="pageno"
                        :page-sizes="[5, 10, 15, 20]"
                        :page-size="pagesize"
                        layout="total, sizes, prev, pager, next, jumper"
                        :total="total"
                >
                </el-pagination>
            </div>
            <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="dialogVisible=false">关闭</el-button>
        </span>
        </el-dialog>
    </div>
</template>

<script>
    export default {
        name: "commercial_dialog",
        data(){
            return {
                dialogVisible: false,
                commercialList: [],
                pageno: 1,
                pagesize: 5,
                total: 1,
            }
        },
        methods: {
            getData() {
                let users={
                    commercialState:1,
                    accountState:0
                };
                this.gatherDetailInfoList=[];
                let params = new URLSearchParams();
                params.append("pageno",this.pageno);
                params.append("pagesize",this.pagesize);
                Object.keys(users).forEach(item=>{
                    params.append(item,users[item]);
                })
                this.$axios.get("users.action", {params: params})
                    .then(res => {
                        this.commercialList=res.data.records;
                        this.total = res.data.total;
                    })
                    .catch(err => {
                        this.$message.error(err)
                    })
            },
            handleSizeChange(val) {
                //每页范围
                this.pagesize = val;
                this.getData();
            },
            handleCurrentChange(val) {
                //当前页
                this.pageno = val;
                this.getData();
            },
            select(row){
                //获取选中的商户，存入父组件内
                this.$parent.getCid(row);
                //关闭对话框
                this.dialogVisible=false;
            }
        }
    }
</script>

<style scoped>

</style>